<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .root{
            width: 300px;
            height: 300px;
            background: dodgerblue;
        }
        .box{
            width: 100px;
            height: 100px;
            background: crimson;
        }
        .kkid{
            width: 50px;
            height: 50px;
            background: aliceblue;
        }
    </style>
</head>
<body>
    <div class="root" id="root">
        <div class="box" id="box">
            <div class="kkid" id="kkid"></div>
        </div>
    </div>
    <script>
        var root = document.getElementById('root')
        var box = document.getElementById('box')
        // //over在从父元素进入子元素和子元素进入父元素都会触发，enter不会
        // root.addEventListener('mouseover',function(){
        //     alert('over')
        // })
        // root.addEventListener('mouseenter',function(){
        //     alert('enter')
        // })
        
        //out从父级元素离开进入子级元素也算触发，离开子级元素同样触发，leave要在完全离开父级才算数
        root.addEventListener('mouseout',function(){
            alert('out')
        })
        root.addEventListener('mouseleave',function(){
            alert('leave')
        })

        //over和out对于子元素的子元素也有效果，说明有继承
    </script>
</body>
</html>